using System;
using System.Collections.Generic;
using System.Text;

namespace Core.Items
{
    public class ToDoItem
    {
        private Guid _id = Guid.NewGuid();
        private string _subject = string.Empty;
        private string _description = string.Empty;
        private DateTime _dueDate = new DateTime(3000, 1, 1);
        private int _completionRate = 0;
        private ToDoItemPriority _priority = ToDoItemPriority.Minor;
        private ToDoItemStatus _status = ToDoItemStatus.Open;
        private IList<ToDoItem> _childItems = new List<ToDoItem>();

        public ToDoItem(string subject)
        {
            _subject = subject;        
  
        }

        public Guid Id
        {
            get
            {
                return _id;
            }
        }

        public string Subject
        {
            get
            {
                return _subject;
            }
            set
            {
                _subject = value;
            }
        }

        public string Description
        {
            get
            {
                return _description;
            }
            set
            {
                _description = value;
            }
        }

        public DateTime DueDate
        {
            get
            {
                return _dueDate;
            }
            set
            {
                _dueDate = value;
            }
        }
        public int CompletionRate
        {
            get
            {
                return _completionRate;
            }
            set
            {
                _completionRate = value;
            }
        }
        public ToDoItemPriority Priority
        {
            get
            {
                return _priority;
            }
            set
            {
                _priority = value;
            }
        }

        public ToDoItemStatus Status
        {
            get
            {
                return _status;
            }
            set
            {
                _status = value;
            }
        }

        public IList<ToDoItem> ChildItems
        {
            get
            {
                return _childItems;
            }
        }

        public ToDoItem this[Guid id]
        {
            get
            {
                lock (_childItems)
                {
                    foreach (ToDoItem item in _childItems)
                    {
                        if (item.Id.Equals(id))
                        {
                            return item;
                        }
                    }
                }
                return null;
            }
        }
    }
}
